#!/bin/bash

RWKV_DOWNLOAD_ADDRESS='https://huggingface.co/BlinkDL/rwkv-6-world/resolve/main/RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth?download=true'
RWKV_SHA256_PRESET='cda1f0ebe802e2859bfa129546372fd1eac60319111f215f65ced67dd334db36'

if [ -f 'RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth' ]; then
    rwkv_sha256="$(sha256sum 'RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth')"
    if [ "$rwkv_sha256" != "$RWKV_SHA256_PRESET" ]; then
        echo "RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth sha256 mismatch"
        exit 1
    fi
fi

wget -t 0 --read-timeout=86400 -O 'RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth' "$RWKV_DOWNLOAD_ADDRESS"
rwkv_sha256="$(sha256sum 'RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth')"
if [ "$rwkv_sha256" != "$RWKV_SHA256_PRESET" ]; then
    echo "RWKV-x060-World-1B6-v2.1-20240328-ctx4096.pth sha256 mismatch"
    exit 1
fi
